﻿using System;
using System.Collections.Generic;
using StockLib.UserData;

namespace StockLib
{
    public delegate void StockTabContainerDataEventHandler(object sender, EventArgs e);

    public class StockTabContainer : List<StockTab>
    {
        /// <summary>
        /// 容器数据更改事件
        /// </summary>
        public event StockTabContainerDataEventHandler DataChanged;

        /// <summary>
        /// 单例实例
        /// </summary>
        private static StockTabContainer _instance = new StockTabContainer();

        /// <summary>
        /// 构造函数
        /// </summary>
        private StockTabContainer()
            : base()
        {
        }

        /// <summary>
        /// 访问单例
        /// </summary>
        /// <returns></returns>
        public static StockTabContainer Instance
        {
            get
            {
                return _instance;
            }
        }

        public void Load()
        {
            // 载入板块数据
            StockUserData.Instance.LoadTabData();
        }

        public void Save()
        {
            // 保存板块数据
            StockUserData.Instance.SaveTabData();
        }

        public void RaiseDataChanged(object sender, EventArgs e)
        {
            if (DataChanged != null)
            {
                DataChanged(sender, e);
            }
        }
    }
}
